package org.bbelovic.devel.exercises.number;

public class Recursion {

    public static void main(String[] args) {
        long result = factorial(5);
        System.out.println(result);
    }
    private static long factorial(int n) {
        if (n == 0 || n == 1) {
            return 1L;
        }
        return n*factorial(n-1);
    }
    
    public static void ex233(int n) {
        if (n <= 0) return;
        System.out.println(n);
        ex233(n-2);
        ex233(n-3);
        System.out.println(n);
    }
    
    public static String ex234(int n) {
        if (n <= 0) return "";
        return ex234(n-3) + n + ex234(n-2) + n;
    }
}
